//
//  jxlsViewController.m
//  gpos_app
//
//  Created by apple on 2018/8/29.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "jxlsViewController.h"
#import "Masonry.h"
@interface jxlsViewController ()
@property (nonatomic,strong)UIView * topView;
@property (nonatomic,strong)UILabel *TimeLabel;
@property (nonatomic,strong)NSString * timeStr;

@end

@implementation jxlsViewController

//改变状态栏
-(void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    
}
-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:244/255.0f green:244/255.0f blue:244/255.0f alpha:1];
    self.title = @"账单详情";
    [self topLoadView];
}
- (void)topLoadView {
    self.topView = [[UIView alloc] init];
    self.topView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.topView];
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).with.offset(kNavbarHeight);
        make.left.equalTo(self.view).with.offset(0);
        make.right.equalTo(self.view).with.offset(0);
        make.height.equalTo(@30);
    }];
    
    UILabel * leftLabel = [[UILabel alloc] init];
    leftLabel.font = [UIFont systemFontOfSize:12];
    leftLabel.textColor = [UIColor grayColor];
    [self.topView addSubview:leftLabel];
    [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.topView);
        make.right.equalTo(self.topView).with.offset(-16);
    }];
    
    self.TimeLabel = [[UILabel alloc] init];
    self.TimeLabel.font = [UIFont systemFontOfSize:12];
    self.TimeLabel.textColor = [UIColor lightGrayColor];
    [self.topView addSubview:self.TimeLabel];
    [self.TimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.topView);
        make.left.equalTo(self.topView).with.offset(16);
        
    }];
    
    long endtime = [self.periods longLongValue] *24*60*60*1000+[self.startchuo longLongValue];
    
    NSLog(@"%lu",endtime);
    // timeStampString 是服务器返回的13位时间戳
    NSString *timeStampString  = self.startchuo;
    NSString * endStr = [NSString stringWithFormat:@"%lu",endtime];
    
    // iOS 生成的时间戳是10位
    NSTimeInterval interval=[timeStampString doubleValue] / 1000.0;
    NSTimeInterval endtimeter = [endStr doubleValue] /1000.0;
    NSDate *date  = [NSDate dateWithTimeIntervalSince1970:interval];
    
    
    NSDate * endDate = [NSDate dateWithTimeIntervalSince1970:endtimeter];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateString    = [formatter stringFromDate: date];
    NSString * enddatesteinbg = [formatter  stringFromDate:endDate];
    self.TimeLabel.text = [NSString stringWithFormat:@"第%@期 : %@--%@",self.twoint,dateString,enddatesteinbg];
    if ([self.Aount integerValue] ==1 ) {
        leftLabel.text = @"一等奖";
    }else if ([self.Aount integerValue]  ==2){
        leftLabel.text = @"二等奖";
        
    }else if ([self.Aount integerValue] ==3){
        leftLabel.text = @"三等奖";
        
    }
//    leftLabel.text = @"未竞选上";
    
//    self.timeStr = @"2018-08-20";
//    leftLabel.text = @"第一阶段";
//    self.TimeLabel.text = [NSString stringWithFormat:@"%@(单位:GPOS)",self.timeStr];
    
    UIView * kjsyBGView = [[UIView alloc] init];
    kjsyBGView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:kjsyBGView];
    [kjsyBGView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topView.mas_bottom).with.offset(0);
        make.left.equalTo(self.view).with.offset(0);
        make.right.equalTo(self.view).with.offset(0);
        make.height.equalTo(@180);
    }];
    
   
    UIImageView * kjImageView = [[UIImageView alloc] init];
    kjImageView.image = [UIImage imageNamed:@"icon_jx_hb"];
    [kjsyBGView addSubview:kjImageView];
    [kjImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(kjsyBGView).with.offset(30);
        make.centerX.equalTo(kjsyBGView);
        make.height.equalTo(@47);
    }];

    
    
    UILabel * kjsytishiLabel = [[UILabel alloc] init];
    kjsytishiLabel.font = [UIFont systemFontOfSize:14];
    kjsytishiLabel.textColor = [UIColor blackColor];
    [kjsyBGView addSubview:kjsytishiLabel];
    [kjsytishiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(kjImageView.mas_bottom).with.offset(10);
        make.centerX.equalTo(kjsyBGView);
    }];
    
    
    UILabel * kjzshouyiLabel = [[UILabel alloc] init];
    kjzshouyiLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    kjzshouyiLabel.textColor = [UIColor grayColor];
    [kjsyBGView addSubview:kjzshouyiLabel];
    [kjzshouyiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(kjsytishiLabel.mas_bottom).with.offset(14);
        make.centerX.equalTo(kjsyBGView);
    }];
    kjsytishiLabel.text = @"竞选总收益";
//     NSNumber * nsNumber1 = @([self.fourint floatValue]);
    kjzshouyiLabel.text = [NSString stringWithFormat:@"%@ GPOS",@(self.fourint.floatValue)];
    
    UIView * bottomBGView = [[UIView alloc] init];
    bottomBGView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bottomBGView];
    [bottomBGView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(kjsyBGView.mas_bottom).with.offset(10);
        make.left.equalTo(self.view).with.offset(0);
        make.right.equalTo(self.view).with.offset(0);
        make.height.equalTo(@109);
    }];
    
    UIView * bottomSXView = [[UIView alloc] init];
    bottomSXView.backgroundColor = [UIColor grayColor];
    [bottomBGView addSubview:bottomSXView];
    [bottomSXView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bottomBGView).with.offset(10);
        make.right.equalTo(bottomBGView).with.offset(-10);
        make.centerY.equalTo(bottomBGView);
        make.height.equalTo(@0.5);
    }];
    
    UILabel * bottomkjsyts = [[UILabel alloc] init];
    bottomkjsyts.font = [UIFont systemFontOfSize:14];
    bottomkjsyts.textColor = [UIColor blackColor];
    [bottomBGView addSubview:bottomkjsyts];
    [bottomkjsyts mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomBGView).with.offset(5);
        make.left.equalTo(bottomBGView).with.offset(15);
        make.bottom.equalTo(bottomSXView.mas_top).with.offset(-5);
    }];
    
    UILabel * bottomkjsyje  = [[UILabel alloc] init];
    bottomkjsyje.font = [UIFont systemFontOfSize:14];
    bottomkjsyje.textColor = [UIColor blackColor];
    [bottomBGView addSubview:bottomkjsyje];
    [bottomkjsyje mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomBGView).with.offset(5);
        make.right.equalTo(bottomBGView).with.offset(-15);
        make.bottom.equalTo(bottomSXView.mas_top).with.offset(-5);
    }];
    
    UILabel * bottomtjsyts = [[UILabel alloc] init];
    bottomtjsyts.font = [UIFont systemFontOfSize:14];
    bottomtjsyts.textColor = [UIColor blackColor];
    [bottomBGView addSubview:bottomtjsyts];
    [bottomtjsyts mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomSXView.mas_bottom).with.offset(5);
        make.left.equalTo(bottomBGView).with.offset(15);
        make.bottom.equalTo(bottomBGView).with.offset(-5);
    }];
    
    UILabel * bottomtjsyje  = [[UILabel alloc] init];
    bottomtjsyje.font = [UIFont systemFontOfSize:14];
    bottomtjsyje.textColor = [UIColor blackColor];
    [bottomBGView addSubview:bottomtjsyje];
    [bottomtjsyje mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomSXView.mas_bottom).with.offset(5);
        make.right.equalTo(bottomBGView).with.offset(-15);
        make.bottom.equalTo(bottomBGView).with.offset(-5);
    }];
    
    UIView * jingxuanseView = [[UIView alloc] init];
    jingxuanseView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:jingxuanseView];
    [jingxuanseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomBGView.mas_bottom).with.offset(10);
        make.right.equalTo(self.view).with.offset(0);
        make.left.equalTo(self.view).with.offset(0);
        make.height.equalTo(@50);
    }];
    
    UILabel * jxseLabel  = [[UILabel alloc] init];
    jxseLabel.font = [UIFont systemFontOfSize:14];
    jxseLabel.textColor = [UIColor blackColor];
    [jingxuanseView addSubview:jxseLabel];
    [jxseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(jingxuanseView).with.offset(5);
        make.left.equalTo(jingxuanseView).with.offset(15);
        make.bottom.equalTo(jingxuanseView).with.offset(-5);
    }];
    
    UILabel * jxseTextLabel  = [[UILabel alloc] init];
    jxseTextLabel.font = [UIFont systemFontOfSize:14];
    jxseTextLabel.textColor = [UIColor blackColor];
    [jingxuanseView addSubview:jxseTextLabel];
    [jxseTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(jingxuanseView).with.offset(-15);
        make.centerY.equalTo(jxseLabel);
    }];
    
    bottomkjsyts.text = @"排名";
    bottomtjsyts.text = @"参与人数";
    jxseLabel.text = @"竞选数额";
    bottomkjsyje.text = [NSString stringWithFormat:@"%ld",(long)self.paiming];
    bottomtjsyje.text = [NSString stringWithFormat:@"%ld",self.participant];
//     NSNumber * nsNumber2 = @(self.amount);
    jxseTextLabel.text = [NSString stringWithFormat:@"%@ GPOS",@(self.amount.floatValue)];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
